@{
    ViewData["Title"] = "Home Page";
}
@section Header{
    <link rel="stylesheet" href="~/layui/css/modules/code.css" media="all">
    <link id="layuicss-layer" rel="stylesheet" href="~/layui/css/modules/layer/default/layer.css" media="all">
    <link rel="stylesheet" href="~/layui/css/shCoreDefault.css" media="all">
    <style>
        .syntaxhighlighter td.code .line {
            font-size: 12px !important;
        }

        .syntaxhighlighter .keyword {
            color: #cc86d4 !important;
        }

        .syntaxhighlighter td.code .line {
            line-height: 1.8 !important;
        }

        @@media screen and (max-width: 750px) {
            .code .container {
                word-break: break-all;
            }
        }

        .site-h1 {
            color: #f60 !important;
        }

        .syntaxhighlighter {
            padting-bottom: 20px !important;
            padting-top: 20px !important;
        }

        .gutter {
            display: none;
        }
    </style>
}





<div class="layui-main site-inline">
    @Html.Partial("_ormmenu")
    <div class="site-content">
        <h1 class="site-h1">God_Reply.ORM简介</h1>
        <div>
            <p>
                <div>參考：</div>
                <dl>
                    <dt>
                        <a href="http://elinq.codeplex.com/">ELinq ORM Framework</a>
                    </dt>
                    <dd>
                        ELinq 是一个轻量简单易用的开源Linq ORM数据访问组件，支持Nullable类型和枚举类型，支持根据实体类自动建库建表建关系，支持根据数据库通过T4模版自动生成实体代码，对Linq的谓词提供了完美的支持，旨在让绝大部份的主流数据库都使用 Linq 来进行程序开发，让开发人员访问数据库从SQL中解放出来，易学易用上手快，配置简单，并且提供了源代码下载，方便定制。支持多数据库，目前支持Access、SQLServer、SqlCE、SQLite、MySQL、ORACLE，未来还会支持更多的数据库。

                    </dd>
                </dl>
                <dl>
                    <dt>
                        <a href="http://www.52chloe.com/Wiki/Document">
                            Chloe.ORM
                        </a>
                    </dt>
                    <dd> Chloe is a lightweight Object/Relational Mapping(ORM) library. The query interface is similar to LINQ.You can query data like LINQ and do any things(Join Query | Group Query | Aggregate Query | Insert | Batch Update | Batch Delete) by lambda with Chloe.ORM. </dd>
                </dl>
                <dl>
                    <dt><a href="http://www.codeisbug.com/">SqlSugar</a></dt>
                    <dd>
                        SqlSugar 4.x是一款高性能（达到ADO.NET最高性能水平）、轻量级、支持多库和人性化语法的ORM，语法方便，入门简单，功能强大。

                        对数据库结构没太多要求，支持多主键，多自增列
                    </dd>
                </dl>
                <dl><dt><a href="http://lko2o.com/moon/article/3">Moon.Orm</a> </dt><dd>  Moon.Orm,意在打造高性能、易用、便捷、易于维护、多数据库数据源支持的 Orm 框架。 </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/qianxingdewoniu/p/5991413.html">Dos.ORM</a> </dt><dd>Dos.ORM（原名Hxj.Data）于2009年发布，2015年正式开源，该组件已在数百个成熟项目中应用，是目前国内用户量最大、最活跃、最完善的国产ORM。初期开发过程中参考了NBear与MySoft，吸取了他们的一些精华，加入新思想，后期参考EF的Lambda语法进行大量扩展。 </dd></dl>
                <dl><dt><a href="https://github.com/cyq1162/cyqdata">cyq.data</a> </dt><dd>cyq.data is not only a orm,but also a data access layer,it's very special and diffirent from others,who use who love it. </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/TextEditor/archive/2011/06/26/2090389.html">wojilu ORM</a></dt> <dd>wojilu ORM 尽量设计得简单易用，从下图可以看出，总共也就9个方法(重载方法不算)。 </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/wzxinchen/p/4700506.html">xlinq</a> </dt><dd>高性能ORM框架XLinq </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/bluedoctor/p/3378683.html"> PDF.NET</a> </dt><dd>一个具有SQL-MAP、ORM、Data Control功能的数据开发框架：PDF.NET Ver 1.0 诞生了！现在更名为SOD框架，就是根据这个顺序过程来的。 </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/steden/archive/2013/01/22/2871160.html">Farseer.net</a> </dt><dd>如果可以，希望Farseer.net 能让你解放双手！ </dd></dl>
                <dl><dt><a href="http://www.cnblogs.com/StrangeCity/p/5566471.html">Deft</a></dt> <dd>Deft是一个超轻量级高性能O/R mapping数据访问框架，简单易用，几分钟即可上手。 </dd></dl>
            </p>
            <p><br /></p><p><br /></p><p><strong>官方QQ群：</strong>&nbsp;225982985</p><p><br /></p><p>God_Reply.ORM 1.x是一款高性能（达到ADO.NET最高性能水平）、轻量级、支持多库和人性化语法的ORM，语法方便，入门简单，功能强大。<br /></p><p><br /></p><p>对数据库结构没太多要求，支持多主键，多自增列</p><p><br /></p><p><br /></p><p><br /></p><p><span style="color: rgb(192, 80, 77);"><strong>一、EF分页 VS Sugar分页</strong></span></p><p><br /></p><p><span style="font-size: 12px;"><strong>1.SqlSugar 3表查询分页</strong></span></p><pre class="brush:c#;toolbar:false">var&nbsp;list&nbsp;=&nbsp;db.Queryable&lt;Student,&nbsp;School,School&gt;((st,&nbsp;sc,sc2)&nbsp;=&gt;&nbsp;new&nbsp;object[]&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;JoinType.Left,st.SchoolId==sc.Id,
&nbsp;&nbsp;&nbsp;&nbsp;JoinType.Left,sc.Id==sc2.Id
})
.Select((st,sc)=&gt;new&nbsp;{id=&nbsp;st.Id,name=st.Name,t=sc.X}).ToPageList(pageIndex,pageSize,ref&nbsp;total);</pre><p><br /></p><p><span style="font-size: 12px;"><strong>2.EF 2表查询分页</strong></span></p><pre class="brush:c#;toolbar:false">var&nbsp;queryable&nbsp;=&nbsp;(from&nbsp;a&nbsp;in&nbsp;StudentList
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;join&nbsp;b&nbsp;in&nbsp;SchoolList1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on&nbsp;a.Id&nbsp;equals&nbsp;b.Id&nbsp;into&nbsp;b1
&nbsp;&nbsp;&n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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
var&nbsp;listp&nbsp;=&nbsp;queryable.Skip((pageIndex&nbsp;-&nbsp;1)&nbsp;*&nbsp;pageSize).Take(pageSize).ToList();
var&nbsp;total&nbsp;=&nbsp;queryable.Count();</pre><p>比较中不难看出语法王的EF，2表的代码量要比SqlSugar3表的代码还要多，特别是多表查询EF语法太过复杂</p><p><br /></p><p><br /></p><p><span style="color: rgb(192, 80, 77);"><strong>二、EF条件查询 VS Sugar条件查询</strong></span></p><p><span style="color: rgb(192, 80, 77);"><strong><br /></strong></span></p><ol class=" list-padtingleft-2" style="list-style-type: decimal;"><li><p><strong><span style="font-size: 12px;">EF条件查询</span></strong></p></li></ol><pre class="brush:c#;toolbar:false">var&nbsp;queryable&nbsp;=&nbsp;db.Queryable&lt;Student&gt;();
if&nbsp;(!string.IsNullOrEmpty(a))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;queryable&nbsp;=&nbsp;queryable.Where(it&nbsp;=&gt;&nbsp;it.Name&nbsp;==&nbsp;a);
}
if&nbsp;(!string.IsNullOrEmpty(b))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;queryable&nbsp;=&nbsp;queryable.Where(it&nbsp;=&gt;&nbsp;it.Name&nbsp;==&nbsp;b);
}
var&nbsp;list&nbsp;=&nbsp;queryable.ToList();</pre><p><br /></p><p><strong><span style="font-size: 12px;">2. Sugar条件查询</span></strong></p><pre class="brush:c#;toolbar:false">var&nbsp;list&nbsp;=&nbsp;db.Queryable&lt;Student&gt;()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.WhereIF(!string.IsNullOrEmpty(a),it&nbsp;=&gt;&nbsp;it.Name&nbsp;==&nbsp;a)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.WhereIF(!string.IsNullOrEmpty(b),&nbsp;it&nbsp;=&gt;&nbsp;it.Name&nbsp;==&nbsp;b).ToList();</pre><p><strong><span style="font-size: 12px;"></span></strong><br /></p><p>从上面两个例子可以看出，SqlSugar在语法上面可以说是精打细算，如果你还有兴趣可以看下一页。</p><p><br /></p><p><br /></p><p><span style="color: rgb(192, 80, 77);"><strong>三、将结果查询到新类, &nbsp;我们想要的Sql是这样的 Select &nbsp;表a.*,表b.Name &nbsp;as BName &nbsp;from &nbsp;A JOIN B&nbsp;</strong></span></p><p><span style="color: rgb(192, 80, 77);"><strong><br /></strong></span></p><p><strong>1.EF查询</strong></p><pre class="brush:c#;toolbar:false">.Select((a,b)=&gt;new&nbsp;VModel{id=a.id,name=a.name,xx=a.xx&nbsp;.......这里有几十个字段,&nbsp;BName=b.name}).ToList()</pre><p><strong style="white-space: normal;">1.SqlSugar查询</strong></p><pre class="brush:c#;toolbar:false">.Select((a,b)=&gt;new&nbsp;VModel{id=SqlFunc.GetSelfAndAutoFill(a.id),&nbsp;BName=b.name}).ToList()</pre><p><br /></p>
        </div>

    </div>
    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon"></i>
    </div>
</div>

@section Scripts{

    <script src="~/layui/shCore.js" charset="utf-8" asp-append-version="true"></script>
    <script>
        layui.config({
            base: '/_theme/layui-v1.0.3/layui/lay/modules/'
            , version: '31111'
        }).use('global');

        window.global = {
            preview: function () {
                var preview = document.getElementById('LAY_preview');
                return preview ? preview.innerHTML : '';
            }()
        };
    </script>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
}